from BaseIO import BaseIO
from dmx.NetlinxDMX import NetlinxDMX
from osc.osc_io import oscIO

class CommDispatcher(BaseIO):
    def __init__(self, **kwargs):
        super(CommDispatcher, self).__init__(**kwargs)
        
        self.dmx_io = {'NetlinxDMX':NetlinxDMX(hostaddr='192.168.1.9', hostport=1998)}
        
        osc_kwargs = kwargs.get('osc_kwargs', {})
        self.osc_io = oscIO(**osc_kwargs)
        
    def do_connect(self, **kwargs):
        for dmx in self.dmx_io.itervalues():
            dmx.do_connect()
        self.osc_io.do_connect()
        print 'connect'
        self.connected = True
        
    def do_disconnect(self, **kwargs):
        for dmx in self.dmx_io.itervalues():
            dmx.do_disconnect()
        self.osc_io.do_disconnect()
        print 'disconnect'
        self.connected = False
